import 'package:enterprise_v6_app/app/components/custom_app_bar.dart';
import 'package:enterprise_v6_app/app/components/custom_modele/custom_card.dart';
import 'package:enterprise_v6_app/app/components/custom_modele/custom_row_title.dart';
import 'package:enterprise_v6_app/app/core/core.dart';
import 'package:enterprise_v6_app/app/core/ext/widget_extension.dart';
import 'package:enterprise_v6_app/app/core/utils/interface.dart';
import 'package:enterprise_v6_app/app/data/entities/application/execute_entity.dart';

/// 气体分析
class GasAnalysisPage extends StatelessWidget {
  const GasAnalysisPage({super.key});

  @override
  Widget build(BuildContext context) {
    final List<ExecuteTicketGasList> ticketGasList = Get.arguments as List<ExecuteTicketGasList>;
    return Scaffold(
      backgroundColor: AppColors.bg_color_grey,
      appBar: CustomAppBar(
        titleText: '气体分析',
      ),
      body: Container(
        padding: EdgeInsets.all(16.w),
        child: ListView.separated(
          itemCount: ticketGasList.length,
          itemBuilder: (context, index) {
            final item = ticketGasList[index];
            return CustomCard(
              // title: '气体分析人：${item.sampleUserName}',
              titleWidget: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  Row(
                    children: [
                      Container(
                        height: 12.w,
                        width: 3.w,
                        decoration: BoxDecoration(
                          color: Colors.blue,
                          borderRadius: BorderRadius.circular(6.w),
                        ),
                      ),
                      AppGaps.hGap10,
                      Text(
                        '气体分析人',
                        style: TextStyle(
                          fontSize: 16.sp,
                          fontWeight: FontWeight.w500,
                        ),
                      )
                    ],
                  ),
                  Wrap(
                    // spacing: 2.w, // 主轴(水平)方向间距
                    runSpacing: 10.w, // 纵轴（垂直）方向间距
                    direction: Axis.horizontal,
                    children: item.sampleUserSign!.map<Widget>((item) {
                      return Container(
                        margin: EdgeInsets.only(top: 8.w, right: 8.w),
                        width: 76.w,
                        height: 36.w,
                        decoration: BoxDecoration(
                            borderRadius: BorderRadius.circular(4.w),
                            color: Colors.white,
                            border: Border.all(
                              color: const Color(0xFFEFF2F6),
                              width: 1,
                            ),
                            image: DecorationImage(
                              image: NetworkImage(Interface.fileUrl + item),
                            )),
                      ).clickShowLarge(url: Interface.fileUrl + item);
                    }).toList(),
                  )
                ],
              ),
              content: ListView.separated(
                shrinkWrap: true,
                physics: const NeverScrollableScrollPhysics(),
                itemCount: item.workGasJsonDTOList!.length,
                itemBuilder: (context, i) {
                  return Container(
                    padding: EdgeInsets.all(8.w),
                    decoration: BoxDecoration(
                      color: const Color(0xFFF7F7FB),
                      borderRadius: BorderRadius.circular(6.w),
                      border: Border.all(
                        color: const Color(0xFFEBEDF0),
                        width: 1.w,
                      ),
                    ),
                    child: Column(
                      children: [
                        CustomRowTitle(
                          title: '气体分析时间：',
                          content: '${item.sampleDate}',
                        ),
                        CustomRowTitle(
                          title: '气体名称：',
                          content: '${item.workGasJsonDTOList![i].gasName}',
                        ),
                        CustomRowTitle(
                          title: '气体类型：',
                          content: '${item.workGasJsonDTOList![i].gasTypeName}',
                        ),
                        CustomRowTitle(
                          title: '分析结果：',
                          content: '${item.workGasJsonDTOList![i].gasResult}',
                        ),
                        Visibility(
                          visible: item.workGasJsonDTOList![i].gasQualified!.isNotEmpty,
                          child: CustomRowTitle(
                            title: '合格标准：',
                            content: '${item.workGasJsonDTOList![i].gasQualified}',
                          ),
                        ),
                      ],
                    ),
                  );
                },
                separatorBuilder: (context, index) {
                  return AppGaps.vGap16;
                },
              ),
            );
          },
          separatorBuilder: (context, index) {
            return AppGaps.vGap16;
          },
        ),
      ),
    );
  }
}
